package com.red.work.demo;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;

/**
 * 一键清除历史图片
 */
public class ClearHistoryData {

    private static Logger logger = LoggerFactory.getLogger(ClearHistoryData.class);

    public static void main(String[] args) {
        createEmptyFile(getBasePath());
    }

    private static void createEmptyFile(String basePath) {

        clearPathFile(basePath + "/img/0.1开始图表");

        clearPathFile(basePath + "/img/0.2去重数据");

        clearPathFile(basePath + "/img/0.3合作前数据");

        clearPathFile(basePath + "/img/0.4合作前数据2");

        clearPathFile(basePath + "/img/0.5用户分析");

        clearPathFile(basePath + "/img/1.1首页热门楼盘");

        clearPathFile(basePath + "/img/1.2项目详情页");

        clearPathFile(basePath + "/img/1.3项目详情手机页");

        clearPathFile(basePath + "/img/2.1新房列表页右侧橱窗");

        clearPathFile(basePath + "/img/2.2新房房源频道右侧橱窗");

        clearPathFile(basePath + "/img/2.3看房团频道右侧橱窗");

        clearPathFile(basePath + "/img/3.1优惠楼盘列表优先");

        clearPathFile(basePath + "/img/4.1活动信息展示+热门活动频道");

        clearPathFile(basePath + "/img/4.2活动信息展示+热门活动频道-手机");

        clearPathFile(basePath + "/img/5.1竞品项目活动植入");

        clearPathFile(basePath + "/img/6.1首页热门导购");

        clearPathFile(basePath + "/img/6.1首页热门导购");

        clearPathFile(basePath + "/img/6.2搜索零少结果页优先展示");

        clearPathFile(basePath + "/img/6.3首页新房推荐");

        clearPathFile(basePath + "/img/7.1新盘列表三联图");

        clearPathFile(basePath + "/img/7.2新房筛选列表");

        clearPathFile(basePath + "/img/7.3新房筛选列表-手机");

        clearPathFile(basePath + "/img/8.1竞品项目活动-置业顾问植入");

        clearPathFile(basePath + "/img/9.1二手房3区域10板块引流");

        clearPathFile(basePath + "/img/9.2二手房3区域10板块引流-手机");

        clearPathFile(basePath + "/img/90.1二手房PC端房源单页右侧新房推荐");

        clearPathFile(basePath + "/img/90.2新房三端竞品植入");

        clearPathFile(basePath + "/img/90.3二手房PC端精准搜索直达");

        clearPathFile(basePath + "/img/91.1新房移动端（APP、TW）搜索-热搜推荐");

        clearPathFile(basePath + "/img/94.1专属头图-400大号-置业顾问端口");

        clearPathFile(basePath + "/img/96.1全幕名片");

        clearPathFile(basePath + "/img/98.1强势曝光");

        clearPathFile(basePath + "/img/99.1VR售楼处&VR样板间全覆盖+同屏带看功能开通");

        clearPathFile(basePath + "/img/990.1早报开屏");

        clearPathFile(basePath + "/img/991.1开发商供稿不限次数");

        clearPathFile(basePath + "/img/992.1画报-楼评1篇");

        clearPathFile(basePath + "/img/992.2文章导购1篇");

        clearPathFile(basePath + "/img/993.1百度关键词");

        clearPathFile(basePath + "/img/994.1专车一对一线下接送客户");

        clearPathFile(basePath + "/img/995.1单日付费金额高优先");

        clearPathFile(basePath + "/img/996.1免费楼盘单页--推荐合作盘");

    }

    private static void clearPathFile(String filePath){
        File file = new File(filePath);

        if (!file.exists()) {
            logger.info("file is not exist" + filePath);
            file.mkdirs();
            return;
        }

        // 扫描文件夹
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File f : files) {
                f.delete();
            }
        } else {
            // 文件夹场景
            file.delete();
        }
    }

    private static String getBasePath() {
        String resources = ClearHistoryData.class.getClassLoader().getResource("").getPath();
        return resources.replace("/target/classes", "") + "src/main/resources";
    }

    /**
     *
     * 首页热门楼盘
     * 新房列表页右侧橱窗
     * 新房房源频道右侧橱窗
     * 看房团频道右侧橱窗
     * 优惠楼盘列表优先
     * 活动信息展示
     * 热门活动频道
     * 竞品项目活动植入*5个楼盘
     * 首页热门导购
     * 搜索零少结果页优先展示
     * 首页新房推荐
     * 新盘列表三联图（在售状态展示）
     * 新房筛选列表 （三个区域十个板块）
     * 置业顾问竞品植入*5个楼盘
     * 二手房3区域10板块引流
     * 二手房PC端房源单页右侧新房推荐
     * 新房三端竞品植入（楼盘）-楼单看了又看*＞5个盘
     * 二手房PC端精准搜索直达（精准搜索楼盘名）
     * 新房移动端（APP、TW）搜索-热搜推荐
     * 专属头图
     * 400大号
     * 全幕名片
     * 置业顾问端口*（建议6个）
     * 强势曝光
     * VR售楼处&VR样板间全覆盖+同屏带看功能开通
     * 早报开屏
     * 开发商供稿不限次数
     * 画报/楼评1篇
     * 文章导购1篇（PC首页“实地探盘”位置推广）
     * 站外引流（app)
     * 站外引流（tw)
     * 专车一对一线下接送客户
     * 单日付费金额高优先
     *
     *
     */

}
